package com.yaorange.jk.service.impl;

import com.yaorange.jk.dao.BaseDao;
import com.yaorange.jk.entity.Product;
import com.yaorange.jk.service.ProductService;
import com.yaorange.jk.utils.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Transactional
@Service
public class ProductServiceImpl implements ProductService {
    @Autowired
    private BaseDao<Product,String> productDao;

    @Override
    public Pagination findPage(Pagination page) {
    return productDao.pageByHql("from Product",page.getPageNo(),page.getPageSize(),null);
    }

    @Override
    public List<Product> findAll() {
        return productDao.getListByHQL("from Product");
    }

    @Override
    public void save(Product model) {
    productDao.save(model);
    }

    @Override
    public void deleteById(String id) {
    productDao.deleteById(Product.class,id);
    }

    @Override
    public void update(Product model) {
    productDao.update(model);
    }

    @Override
    public Product findById(String id) {
    return productDao.get(Product.class,id);
    }
}
